﻿<Window x:Class="ClearMine.Dialogs.StatisticsWindow" x:ClassModifier="internal" x:Name="root"
        xmlns:b="clr-namespace:ClearMine.Framework.Behaviors;assembly=ClearMine.Framework"
        xmlns:h="clr-namespace:ClearMine.Framework.Controls;assembly=ClearMine.Framework"
        xmlns:c="clr-namespace:ClearMine.GameDefinition;assembly=ClearMine.GameDefinition"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:t="clr-namespace:ClearMine.Framework.Controls;assembly=ClearMine.Framework"
        t:WindowExt.ResizeMode="NoResize"
        h:CommandsHelper.LoadBindingsFromVM="True"
        Background="{StaticResource DialogBackground}"
        TextOptions.TextFormattingMode="Display"
        WindowStartupLocation="CenterOwner"
        SizeToContent="WidthAndHeight"
        ShowInTaskbar="False"
        ResizeMode="NoResize"
        Style="{DynamicResource MainWindowStyle}"
        Title="{DynamicResource StatisticsDialogTitle}">
    <DockPanel Margin="12">
        <DockPanel DockPanel.Dock="Top" Margin="0,0,0,12">
            <ListBox ItemsSource="{Binding HistoryList}"
                     DisplayMemberPath="LevelForDisplay"
                     SelectedValuePath="Level"
                     SelectedValue="{Binding SelectedLevel}"
                     IsSynchronizedWithCurrentItem="True"
                     MinWidth="90" Margin="0,0,12,0" />
            <Grid DataContext="{Binding HistoryList./}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="5" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Margin="0,0,12,0" Grid.Row="0" Content="{DynamicResource GamePlayedLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="2" Content="{DynamicResource GameWonLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="4" Content="{DynamicResource GameWonRateLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="6" Content="{DynamicResource WinningStreakLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="8" Content="{DynamicResource LosingStreakLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="10" Content="{DynamicResource CurrentStreakLabel}" />
                <Label Margin="0,0,12,0" Grid.Row="12" Content="{DynamicResource AverageScoreLabel}" />
                <TextBlock Grid.Column="1" Grid.Row="0" TextAlignment="Right" Text="{Binding GamePlayed}" />
                <TextBlock Grid.Column="1" Grid.Row="2" TextAlignment="Right" Text="{Binding GameWon}" />
                <TextBlock Grid.Column="1" Grid.Row="4" TextAlignment="Right" Text="{Binding GameWonPercentage, StringFormat={}{0:P}}" />
                <TextBlock Grid.Column="1" Grid.Row="6" TextAlignment="Right" Text="{Binding LongestWinning}" />
                <TextBlock Grid.Column="1" Grid.Row="8" TextAlignment="Right" Text="{Binding LongestLosing}" />
                <TextBlock Grid.Column="1" Grid.Row="10" TextAlignment="Right" Text="{Binding CurrentStatus}" />
                <TextBlock Grid.Column="1" Grid.Row="12" TextAlignment="Right" Text="{Binding AverageScore, StringFormat={}{0:F2}}" />
            </Grid>
        </DockPanel>
        <DockPanel DockPanel.Dock="Bottom" LastChildFill="False">
            <Button Content="{DynamicResource ResetButtonLabel}"
                    CommandParameter="{Binding HistoryList}"
                    Command="{x:Static c:GameCommands.Reset}" />
            <Button Content="{DynamicResource OKButtonLabel}"
                    IsDefault="True"
                    IsCancel="True"
                    DockPanel.Dock="Right" />
        </DockPanel>
        <DockPanel DataContext="{Binding HistoryList}"
                   Margin="0,0,0,16">
            <Label DockPanel.Dock="Top" Margin="0,0,0,5"
                   Content="{DynamicResource PlayedHistoryLabel}" />
            <ListView DataContext="{Binding /}"
                      ItemsSource="{Binding Items}"
                      Height="150"
                      IsSynchronizedWithCurrentItem="True">
                <ListView.Resources>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="TextAlignment" Value="Right" />
                        <Setter Property="TextTrimming" Value="CharacterEllipsis" />
                    </Style>
                </ListView.Resources>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}"
                           BasedOn="{StaticResource {x:Static GridView.GridViewItemContainerStyleKey}}">
                        <Setter Property="ToolTip">
                            <Setter.Value>
                                <ToolTip MaxHeight="175" MaxWidth="300">
                                    <Image Source="{Binding ScreenShootUri}"
                                           Margin="7" Stretch="Uniform" />
                                </ToolTip>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="{DynamicResource PlayedHistoryScoreColumnLabel}" Width="50"
                                        b:SortableListViewBehavior.SortField="Score"
                                        DisplayMemberBinding="{Binding Score, StringFormat=0.00}" />
                        <GridViewColumn Header="{DynamicResource PlayedHistoryDateColumnLabel}" Width="160"
                                        b:SortableListViewBehavior.SortField="Date"
                                        DisplayMemberBinding="{Binding Date}" />
                    </GridView>
                </ListView.View>
            </ListView>
        </DockPanel>
    </DockPanel>
</Window>
